﻿//===================================================================================
// Copyright (c) Ryan Garrett.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===================================================================================
using System;

//TODO: Allow case-insentive comparisons

namespace Caffeine.Core.ModelProperty
{
    internal sealed class StringProperty : ModelProperty<String>
    {
        public StringProperty(ModelBase parent, String name, Nullable<ModelPropertyBehaviors> behavior, Boolean isWrapped)
            : base(parent, name, behavior, isWrapped)
        {
        }

        public override String ToString()
        {
            String stringValue = null;

            if (Value != null)
            {
                stringValue = Value.ToString();
            }

            return stringValue;
        }

        internal override void MergeAdjacentProperty(ModelPropertyBase property)
        {
            Value = (property as StringProperty).Value;
        }

        protected override Boolean OnCompareValues(String currentValue, String newValue)
        {
            return currentValue == newValue;
        }
    }
}
